from  selenium import  webdriver
import  time
from  selenium.webdriver.chrome.service import  Service
#By类，用于定位元素
from selenium.webdriver.common.by import   By
#显示等待相关的类
from  selenium.webdriver.support.ui import WebDriverWait
from  selenium.webdriver.support import expected_conditions as  EC
#超时异常
from selenium.common.exceptions import TimeoutException

service = Service("d:/chromedriver/chromedriver-win64/chromedriver.exe")
driver = webdriver.Chrome(service=service)
driver.get("https://movie.douban.com/typerank?type_name=%E5%89%A7%E6%83%85&type=11&interval_id=100:90&action=")
try:
    element = WebDriverWait(driver,10).until(
        EC.presence_of_element_located((By.ID,"footer"))
    )
except TimeoutException:
    print("已经超时")
finally:
    print(driver.page_source.encode("GBK","ignore").decode("GBK"))
    driver.quit()  #关闭
